#! /usr/bin/python3
# codings=utf-8
# @time: 2025/10/13 19:31
# @Author:鹤川
from common.doFile import myLogger


class DoYunSuan():
    # 行为，功能
    def mySum(self, a, b):
        try:
            myLogger.info("执行加法操作")
            if isinstance(a,(int,float)) and isinstance(b,(int,float)):
                c = a + b
                if isinstance(a,(float)) or isinstance(b,(float)):
                    c=round(c,2) # 四舍五入 保留两位小数
            else:
                return "您是非法输入！"
        except Exception as e:
            print(f"处理加法mySum发生异常了，异常信息是{e}")
            myLogger.error(f"执行加法操作失败：{e}")
        else:
            print("未发生异常")
            myLogger.info("执行加法操作成功")
            return c
        finally:
            myLogger.info("执行加法操作结束")

    def myJian(self, a, b):
        try:
            myLogger.info("执行减法操作")
            if isinstance(a,(int,float)) and isinstance(b,(int,float)):
                c = a - b
                if isinstance(a,(float)) or isinstance(b,(float)):
                    c=round(c,2) # 四舍五入 保留两位小数
            else:
                return "您是非法输入！"
        except Exception as e:
            print(f"处理减法myJian发生异常了，异常信息是{e}")
            myLogger.error(f"执行减法操作失败：{e}")
        else:
            print("未发生异常")
            myLogger.info("执行减法操作成功")
            return c
        finally:
            myLogger.info("执行减法操作结束")

    def myCheng(self, a, b):
        try:
            myLogger.info("执行乘法操作")
            if isinstance(a,(int,float)) and isinstance(b,(int,float)):
                c = a * b
                if isinstance(a,(float)) or isinstance(b,(float)):
                    c=round(c,2) # 四舍五入 保留两位小数
            else:
                return "您是非法输入！"
        except Exception as e:
            print(f"处理乘法myCheng发生异常了，异常信息是{e}")
            myLogger.error(f"执行乘法操作失败：{e}")
        else:
            print("未发生异常")
            myLogger.info("执行乘法操作成功")
            return c
        finally:
            myLogger.info("执行乘法操作结束")

    def myChu(self, a, b):
        try:
            myLogger.info("执行除法操作")
            if isinstance(a,(int,float)) and isinstance(b,(int,float)):
                c = a / b
                if isinstance(a,(float)) or isinstance(b,(float)):
                    c=round(c,2) # 四舍五入 保留两位小数
            else:
                return "您是非法输入！"
        except Exception as e:
            print(f"处理除法myChu发生异常了，异常信息是{e}")
            myLogger.error(f"执行除法操作失败：{e}")
        else:
            print("未发生异常")
            myLogger.info("执行除法操作成功")
            return c
        finally:
            myLogger.info("执行除法操作结束")


if __name__ == '__main__':
    ys = DoYunSuan()
    # print(ys.mySum(10.45, 20.55))
    # print(ys.myJian(9.999999, 6.666666))
    # print(ys.myCheng(10,20))
    # print(ys.myChu(10, 0))


    # f1 = lambda a, b: a + b
    # f2 = lambda a, b: a - b
    # f3 = lambda a, b: a * b
    # f4 = lambda a, b: a / b
    # print(f1(10, 20))
    # print(f2(10, 20))
    # print(f3(10, 20))
    # print(f4(10, 20))
























